#include <iostream>
#include "Sales_data.h"

using namespace std;
int main()
{
    Sales_data total;
    if(read(std::cin, total)) { // 读入第一笔交易
        Sales_data trans;
        while (read(std::cin, trans)) {
            if(total.isbn() == trans.isbn())
                total.combine(trans);
            else {
                print(cout, total) << endl;
                total = trans;
            }
        }
        print(cout, total) << endl;
    } else {
        cerr << "No data?!" << endl;
    }


    return 0;
}